From 06b8f9d3ab6844053e108d533852edc2ff4a5399 Mon Sep 17 00:00:00 2001 From: Tim Deegan Date: Fri, 8 Sep 2006 18:55:53 +0100 Subject: [PATCH] [XEND] balloon enough memory to enable shadow mode before live migration.a Signed-off-by: Tim Deegan --- tools/python/xen/xend/XendDomain.py | 4 ++++ tools/python/xen/xend/XendDomainInfo.py | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/tools/python/xen/xend/XendDomain.py b/tools/python/xen/xend/XendDomain.py index 10f9c3b6e0..e9eb8981d2 100644 --- a/tools/python/xen/xend/XendDomain.py +++ b/tools/python/xen/xend/XendDomain.py @@ -420,6 +420,10 @@ class XendDomain: """ The following call may raise a XendError exception """ dominfo.testMigrateDevices(True, dst) + if live: + """ Make sure there's memory free for enabling shadow mode """ + dominfo.checkLiveMigrateMemory() + if port == 0: port = xroot.get_xend_relocation_port() try: diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 033d92ffc4..6a7ad82f9a 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -49,6 +49,7 @@ from xen.xend.xenstore.xstransact import xstransact, complete from xen.xend.xenstore.xsutil import GetDomainPath, IntroduceDomain from xen.xend.xenstore.xswatch import xswatch +from xen.xend import arch """Shutdown code for poweroff.""" DOMAIN_POWEROFF = 0 @@ -1503,6 +1504,19 @@ class XendDomainInfo: ## public: + def checkLiveMigrateMemory(self): + """ Make sure there's enough memory to migrate this domain """ + overhead_kb = 0 + if arch.type == "x86": + # 1MB per vcpu plus 4Kib/Mib of RAM. This is higher than + # the minimum that Xen would allocate if no value were given. + overhead_kb = self.info['vcpus'] * 1024 + self.info['maxmem'] * 4 + overhead_kb = ((overhead_kb + 1023) / 1024) * 1024 + # The domain might already have some shadow memory + overhead_kb -= xc.shadow_mem_control(self.domid) * 1024 + if overhead_kb > 0: + balloon.free(overhead_kb) + def testMigrateDevices(self, network, dst): """ Notify all device about intention of migration @raise: XendError for a device that cannot be migrated -- 2.30.2